import http from '../index'

// 获取小程序授权信息
export const getAuthInfo = () => {
    return http.post("program/get-auth-info")
}

// 获取小程序版本信息
export const getVersionInfo = () => {
    return http.post("program/get-version-info")
}

// 获取小程序体验版二维码
export const getTrialQRCode = () => {
    return http.get("program/get-trial-qr-code")
}

// 获取小程序可回退的版本
export const getRevertcoderelease = () => {
    return http.get("program/get-revert-code-release")
}

// 回退版本
export const backVersion = ({ appVersion }) => {
    return http.get("program/" + appVersion + "/fall-back-version")
}

// 查询最新一次提交的审核状态
export const getReviewStatus = () => {
    return http.post("program/audit_status")
}

// 小程序提交代码
export const commitMiniAppCode = ({ entType }) => {
    return http.post("program/commit?entType=" + entType)
}

// 小程序提交审核
export const submitMiniAppReview = ({ entType }) => {
    return http.post("program/submit-audit?entType=" + entType)
}

// 小程序撤回审核
export const withdrawMiniAppReview = () => {
    return http.post("program/undo-code-audit")
}

// 小程序发布
export const releaseMiniApp = () => {
    return http.post("program/release")
}

// 小程序更新记录
export const getUpdateRecord = ({ entType, ascended = null, current = null, size = null, sortFieldName = null }) => {
    return http.get("program/version-commit", { entType, ascended, current, size, sortFieldName })
}

// 获取草稿箱列表
export const getDrafts = () => {
    return http.get("program/template-draft-list")
}

// 将草稿添加到模板库
export const addDraftToTemplate = ({ draftId }) => {
    return http.post("program/" + draftId + "/add-to-template")
}

// 判断小程序是否授权
export const getMiniAppAuthorizeStatus = () => {
    return http.get("program/authorizationType")
}

// 点击授权微信小程序
export const authorizeMiniApp = ({ callBackUrl }) => {
    return http.get("program/authorization", { callBackUrl })
}